function plotDecisionBoundary(theta, X, y)
    %   Plot the data
    plotData(X(:,2:3), y);
    %   Keep the previous plot visible
    hold on;
    %   Just two features
    if size(X, 2) <= 3
        %   Only need two points to define a line, so choose two endpoints
        plot_x = [min(X(:, 2)) - 2,  max(X(:, 2)) + 2];
        %   Calculate the decision boundary line
        plot_y = (-1 ./ theta(3)) .* (theta(2) .* plot_x + theta(1));
        %   Plot the line
        plot(plot_x, plot_y);
        %   Adjust the axes for better viewing
        axis([30, 100, 30, 100]);
    %   More than two features
    else
        %   Initialize the grid range
        u = linspace(-1, 1.5, 50);
        v = linspace(-1, 1.5, 50);
        %   Initialize the z
        z = zeros(length(u), length(v));
        %   Compute z (theta * x) over the grid
        for i = 1:length(u)
            for j = 1:length(v)
                z(i, j) = mapFeature(u(i), v(j)) * theta;
            end
        end
        %   Transpose the z
        z = z';
        %   To plot on the two dimensional space, we should set the z to zero, so we are on the range [0, 0]
        contour(u, v, z, [0, 0], 'LineWidth', 2);
    end
    %   Don't overlay any more plots on this figure
    hold off;
end
